var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin'); //css单独打包
var HtmlWebpackPlugin = require('html-webpack-plugin'); //生成html

module.exports = {

	entry: { //多入口，其实就是产生多个js文件
		libs: ["react", "react-dom", "react-router","redux","react-redux"],
		app: './main.js' //主文件入口
	},

	output: { //入口文件输出配置
		path: __dirname + '/dist/',
		filename: '[name].js?'
	},

	module: {
	    loaders: [
	        {
	            test: /\.json$/,
	            loader: 'json'
	        },
	        {
	            test: /\.js$/,
	            exclude: /node_modules/,
	            loader: 'babel',
	            query: {
	                presets: ['es2015', 'react']
	            }
	        },
	        {
	            test: /\.css$/,
                exclude: /^node_modules$/,
	            loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
	        },
	        {
	            test: /\.less$/,
                exclude: /^node_modules$/,
	            loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader')
	        },
	        {
	            test:  /\.(png|woff|svg|ttf|eot|jps|gif)$/,
	            loader: "url-loader?limit=10000" //限制大小小于10k的
	        }
	    ]
	},

	resolve: {
		extensions: ['', '.web.js', '.js', '.json', '.less', '.css'] //后缀名自动补全
	},

	plugins: [
		new ExtractTextPlugin('[name].css'),
		new HtmlWebpackPlugin({ //根据模板插入css/js等生成最终HTML
			template: __dirname + '/src/template/index.tmpl.html',
			inject: true,
			hash: true
		})
	],

	devServer: {
		port: 8081, //不设的话默认为8080
		colors: true, //终端中输出结果为彩色
		historyApiFallback: true, //不跳转
		inline: true //实时刷新
	}

}